package com.shortlink.admin.controller;

import com.shortlink.common.util.UrlUtils;
import com.shortlink.common.base.Result;
import com.shortlink.common.base.Results;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * URL 控制层
 *
 * @author wp
 */
@RestController
@RequiredArgsConstructor
public class UrlController {
    /**
     * 根据URL获取对应网站的标题
     */
    @GetMapping("/web-api/url/title")
    public Result<String> getTitleByUrl(String url) {
        return Results.success(UrlUtils.getTitleByUrl(url));
    }
}
